package com.java.interfaces.exer3;

/**
 * @author luzhikun
 * @date 2020/12/17-15:40
 */
public class CompaerableCircle extends Circle implements CompareObject {

    public CompaerableCircle(double radius) {
        super(radius);
    }

    @Override
    public int compareTo(Object o) {
        if (this == o) {
            return 0;
        }
        if (o instanceof CompaerableCircle) {
            CompaerableCircle c = (CompaerableCircle) o;
            if (c.getRadius() == this.getRadius()) {
                return 0;
            } else if (c.getRadius() > this.getRadius()) {
                return -1;
            } else if (c.getRadius() < this.getRadius()) {
                return 1;
            }
        } else {
//            return 0;
            throw new RuntimeException("传入的数值不匹配");
        }
        return 0;
    }
}